<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content=
            "maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>工单处理</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css"/>
    <link rel="stylesheet" type="text/css" href="../css/rams.css"/>
    <link rel="stylesheet" type="text/css" href="../css/worksheet_manage.css"/>
</head>
<body style="background-color: #f5f5f5 !important;position: relative">
<header id="header" class="aui-bar aui-bar-nav headerMarginTop" style="background-color: #e9e9e9; color: #434343;position: fixed;font-weight: 700">
    <div class="aui-title">工单处理</div>
    <!--<div class="aui-pull-right" style="margin-top:1rem;width: 13%;height:13%">-->
        <!--<img src="../image/three_points.png">-->
    <!--</div>-->
</header>
<div id="allProcessTitle" class="bodyMarginTop">
    <div class="workSheet_title_left">&nbsp;</div>
    <div class="workSheet_title_right" onclick="showOrClose(this)">全部流程</div>
    <div id="allProcessCountInfo" class="allProcessCountInfo aui-show">
    </div>
</div>
<div id="workSheetDetail" style="margin-bottom: 2.8rem;margin-top: 0.3rem">

</div>
<footer class="aui-bar aui-bar-tab" id="footer" style="background-color: #e7e7e7; color: #292929">
    <div class="redLine"></div>
    <div style="background-color: white">
        <div class="aui-bar-tab-item" tapmode>
            <img class="aui-iconfont"  style="margin-left: 40%" src="../image/gongdanchuli_orange_icon.png">
            <div class="aui-bar-tab-label" style="margin-top: 0.1rem;color: #ff6600">工单处理</div>
        </div>
        <div class="aui-bar-tab-item"  tapmode onclick="openAppointPage(null)">
            <img class="aui-iconfont"  style="margin-left: 38%" src="../image/gailanshitu_icon.png" >
            <div class="aui-bar-tab-label" style="margin-top: 0.1rem">概览视图</div>
        </div>
        <div class="aui-bar-tab-item"  tapmode onclick="openAppointPage(null)">
            <img class="aui-iconfont"  style="margin-left: 37.5%" src="../image/peizhiguanli_icon.png">
            <div class="aui-bar-tab-label" style="margin-top: 0.1rem">配置管理</div>
        </div>
        <div class="aui-bar-tab-item" tapmode onclick="openAppointPage('person_center')">
            <img class="aui-iconfont" style="margin-left: 39%" src="../image/wode_icon.png">
            <div class="aui-bar-tab-label" style="margin-top: 0.1rem">我的</div>
        </div>
    </div>
</footer>
</body>

<script id="all-process-count-info" type="text/template">
    <div class="aui-text-center countInfo" style="padding-left: 1rem !important;" onclick="getWaitWorkSheetList()">
        <div class="countCss waitDisposeCount">{{=it.wait||0}}</div>
        <div class="circle waitDispose">待</div>
        <div class="aui-font-size-12 aui-padded-t-5">待办<p style="line-height: 1.39em;">&nbsp;</p></div>
    </div>
    <div class="aui-text-center countInfo" onclick="getEndWorkSheetList()">
        <div class="countCss alreadyDisposeCount">{{=it.end||0}}</div>
        <div class="circle alreadyDispose">已</div>
        <div class="aui-font-size-12 aui-padded-t-5">已办<p style="line-height: 1.39em;">&nbsp;</p></div>
    </div>
    <div class="aui-text-center countInfo">
        <div class="countCss alreadyPigeonholeCount">停用</div>
        <div class="circle alreadyPigeonhole">归</div>
        <div class="aui-font-size-12 aui-padded-t-5">已归档<p style="line-height: 1.39em;">&nbsp;</p></div>
    </div>
    <div class="aui-text-center countInfo">
        <div class="countCss alreadyRevocationCount">停用</div>
        <div class="circle alreadyRevocation">撤</div>
        <div class="aui-font-size-12 aui-padded-t-5">已撤销<p style="line-height: 1.39em;">&nbsp;</p></div>
    </div>
</script>
<script id="wait-worksheet-detail" type="text/template">
    <div class="workSheet_title_left">&nbsp;</div>
    <div class="workSheet_title_right">{{=it.title}}</div>
    {{?it.list}}
    {{~it.list:info:index}}
    <div class="workSheet_info_card" tapmode onclick="openWorksheetDetail('{{=info.worksheetNo}}','{{=info.processId}}','{{=info.worksheetTitle}}')">
        <div class="malfunctionLevel">
            <div style="color: {{=info.level}};background-color: {{=info.level}};" class="levelCircle"></div>
        </div>
        <div class="worksheetInfo">
            <div>{{=info.worksheetNo||''}}</div>
            <div style="font-size: 0.7rem">
                <div class="worksheetTitle">工单主题：</div>
                <div class="worksheetName">{{=info.worksheetTitle||''}}</div>
            </div>
            <div class="greyLine" style="width: 96%"></div>
            <div class="lastAreaStyle">
                <img class="horologe" src="../image/horologe.png">
                <div class="remainingTimeTitle">剩余时间：</div>
                {{?info.clsssy&&info.clsssy.indexOf("-")==-1}}
                <div class="remainingTimeInfo">{{=info.clsssy||''}}</div>
                {{??}}
                <div class="remainingTimeInfo"  style="color: red">{{=info.clsssy||''}}</div>
                {{?}}
                <div class="worksheetStatusTitle">工单状态：</div>
                <div class="worksheetStatusInfo">{{=info.worksheetStatus||''}}</div>
            </div>
        </div>
        <div class="iconStyle">
            <span class="aui-iconfont aui-icon-right" style="color: #999999 !important;font-weight: 700;"></span>
        </div>
    </div>
    {{~}}
    {{?}}
</script>
<script id="end-worksheet-detail" type="text/template">
    <div class="workSheet_title_left">&nbsp;</div>
    <div class="workSheet_title_right">{{=it.title}}</div>
    {{?it.list}}
    {{~it.list:info:index}}
    <div class="workSheet_info_card" tapmode onclick="openWorksheetDetail('{{=info.worksheetNo}}','{{=info.processId}}','{{=info.worksheetTitle}}')">
        <div class="malfunctionLevel">
            <div style="color: {{=info.level}};background-color: {{=info.level}};" class="levelCircle"></div>
        </div>
        <div class="worksheetInfo">
            <div>{{=info.worksheetNo||''}}</div>
            <div style="font-size: 0.7rem">
                <div class="worksheetTitle">工单主题：</div>
                <div class="worksheetName">{{=info.worksheetTitle||''}}</div>
            </div>
            <div class="greyLine" style="width: 96%"></div>
            <div class="lastAreaStyle">
                <img class="horologe" src="../image/horologe.png">
                <div class="remainingTimeTitle">处理时限（小时）：</div>
                {{?info.dmDealLimit&&info.dmDealLimit.indexOf("-")==-1}}
                <div class="remainingTimeInfo">{{=info.dmDealLimit||''}}</div>
                {{??}}
                <div class="remainingTimeInfo"  style="color: red">{{=info.dmDealLimit||''}}</div>
                {{?}}
                <div class="worksheetStatusTitle">工单状态：</div>
                <div class="worksheetStatusInfo">{{=info.worksheetStatus||''}}</div>
            </div>
        </div>
        <div class="iconStyle">
            <span class="aui-iconfont aui-icon-right" style="color: #999999 !important;font-weight: 700;"></span>
        </div>
    </div>
    {{~}}
    {{?}}
</script>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/doT.min.js"></script>
<script type="text/javascript" src="../script/config.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript" src="../script/aui-tab.js"></script>
<script type="text/javascript" src="../script/aui-tab.js"></script>
<script>
    var times = 0;
    var time1, time2;
    var worksheet='wait';
    apiready = function () {
        api.parseTapmode();
        //下拉刷新
        api.setRefreshHeaderInfo({
            visible: true,
            bgColor: 'rgba(0,0,0,0)',
            textColor: '#666',
            textDown: '下拉刷新',
            textUp: '释放刷新',
            showTime: false
        }, function () {
            refresh();
        });
        getWaitAndEndCount();
        getWaitWorkSheetList();
        keyBackListener()
        //监听keyback返回事件
        api.addEventListener({
            name: 'reload_worksheet_manage'
        },function () {
            var operate_status = $api.getStorage(storageKey.operate_status);
            if (operate_status&&operate_status === "operate_success") {
                window.location.reload();
                $api.setStorage(storageKey.operate_status,"");
            }
        })
    }
    //下拉刷新
    function refresh() {
        api.refreshHeaderLoadDone(); //复位下拉刷新
        getWaitAndEndCount();
        if (worksheet==='wait'){
            getWaitWorkSheetList();
        } else{
            getEndWorkSheetList()
        }
    }


    function keyBackListener() {
        api.addEventListener({
            name: 'keyback'
        }, function (ret, err) {
            if (times == 0) {
                time1 = new Date().getTime();
                times = 1;
                api.toast({
                    msg: '再按一次返回键退出',
                    duration: 2000,
                    location: 'middle'
                });
            } else if (times == 1) {
                time2 = new Date().getTime();
                if (time2 - time1 < 2000) {
                    api.closeWidget({
                        id: api.appId,
                        retData: {
                            name: 'closeWidget'
                        },
                        silent: true
                    });
                } else {
                    times = 0;
                    api.toast({
                        msg: '再按一次返回键退出',
                        duration: 2000,
                        location: 'middle'
                    });
                }
            }
        });
    }
    function getWaitAndEndCount() {
        common.post({
            url: config.waitAndEndWorksheet,
            isLoading: true,
            success: function (ret) {
                var params = []
                if (ret.status=='200'){
                    params = ret.data;
                    if (params.wait > 99){
                        params.wait = '99+'
                    }
                    if (params.end > 99){
                        params.end = '99+'
                    }
                }
                $api.html($api.byId('allProcessCountInfo'), "");
                var allProcessCountInfo = doT.template($api.text($api.byId('all-process-count-info')));
                var params = ret.data;
                $api.html($api.byId('allProcessCountInfo'), allProcessCountInfo(params));
            }
        });
    }
    function getWaitWorkSheetList() {
        worksheet='wait'
        common.post({
            url: config.waitWorksheetListUrl,
            isLoading: true,
            success: function (ret) {
                $api.html($api.byId('workSheetDetail'), "");
                if (ret.status=='200'){
                    var params = [];
                    params.list = ret.data
                    for (var i=0; i<params.list.length; i++){
                        var info = params.list[i]
                        if (info.level === '1010201'){
                            info.level = 'red'
                        }else if (info.level === '1010202'){
                            info.level = 'orange'
                        }else if (info.level === '1010203'){
                            info.level = 'yellow'
                        }else if (info.level === '1010204'){
                            info.level = 'blue'
                        }else{
                            info.level = '#f9f9f9'
                        }
                        if(info.worksheetStatus === '1'){
                            if(info.dealStatus === '0'){
                                if(info.dealType === 'FKCL'){
                                    info.worksheetStatus = '待接单'
                                }else if(info.dealType === 'JG'){
                                    info.worksheetStatus = '待解除挂起'
                                }else if(info.dealType === 'QRJD'){
                                    info.worksheetStatus = '待确认结单'
                                }else if(info.dealType === 'GQSH'){
                                    info.worksheetStatus = '待挂起审核'
                                }else if(info.dealType === 'CS'){
                                    info.worksheetStatus = '待抄送确认'
                                }else if(info.dealType === 'GQPF'){
                                    info.worksheetStatus = '待挂起批复'
                                }else if(info.dealType === 'FDSH'){
                                    info.worksheetStatus = '待退单审核'
                                }
                            }else if(info.worksheetStatus === '1'){
                                if(info.dealType === 'YJD'){
                                    info.worksheetStatus = '已接单'
                                }else if(info.dealType === 'FKCL'){
                                    info.worksheetStatus = '待返单'
                                }else if(info.dealType === 'JG'){
                                    info.worksheetStatus = '解除挂起'
                                }else if(info.dealType === 'QRJD'){
                                    info.worksheetStatus = '确认结单'
                                }else if(info.dealType === 'GQSH'){
                                    info.worksheetStatus = '挂起审核'
                                }else if(info.dealType === 'CS'){
                                    info.worksheetStatus = '抄送确认'
                                }else if(info.dealType === 'GQPF'){
                                    info.worksheetStatus = '挂起批复'
                                }else if(info.dealType === 'FDSH'){
                                    info.worksheetStatus = '退单审核'
                                }
                            }
                        }else if(info.worksheetStatus === '4'){
                            info.worksheetStatus = '挂起中'
                        }
                        if (info.worksheetTitle && info.worksheetTitle.length>45){
                            info.worksheetTitle = info.worksheetTitle.substring(0,45)+ "..."
                        }
                    }
                    params.title='待办工单列表'
                    var worksheetDetail = doT.template($api.text($api.byId('wait-worksheet-detail')));
                    $api.html($api.byId('workSheetDetail'), worksheetDetail(params));
                }else{
                    api.toast({
                        msg: '待办工单列表获取失败！',
                        duration: config.duration,
                        location: 'middle'
                    });
                }
            }
        });

    }
    function getEndWorkSheetList() {
        worksheet = 'end'
        common.post({
            url: config.endWorksheetListUrl,
            isLoading: true,
            success: function (ret) {
                $api.html($api.byId('workSheetDetail'), "");
                if (ret.status=='200'){
                    var params = [];
                    params.list = ret.data
                    for (var i=0; i<params.list.length; i++){
                        var info = params.list[i]
                        if (info.level === '1010201'){
                            info.level = 'red'
                        }else if (info.level === '1010202'){
                            info.level = 'orange'
                        }else if (info.level === '1010203'){
                            info.level = 'yellow'
                        }else if (info.level === '1010204'){
                            info.level = 'blue'
                        }else{
                            info.level = '#f9f9f9'
                        }
                        if(info.worksheetStatus === '1'){
                            info.worksheetStatus = '处理中'
                        }else if(info.worksheetStatus === '2'){
                            info.worksheetStatus = '结单'
                        }else if(info.worksheetStatus === '3'){
                            info.worksheetStatus = '归档'
                        }else if(info.worksheetStatus === '4'){
                            info.worksheetStatus = '挂起'
                        }else if(info.worksheetStatus === '5'){
                            info.worksheetStatus = '撤销'
                        }
                        if (info.worksheetTitle && info.worksheetTitle.length>45){
                            info.worksheetTitle = info.worksheetTitle.substring(0,45)+ "..."
                        }
                    }
                    params.title='已办工单列表'
                    var worksheetDetail = doT.template($api.text($api.byId('end-worksheet-detail')));
                    $api.html($api.byId('workSheetDetail'), worksheetDetail(params));
                }else{
                    api.toast({
                        msg: '已办工单列表获取失败！',
                        duration: config.duration,
                        location: 'middle'
                    });
                }
            }
        });


    }

    function openWorksheetDetail(worksheetNo,processId,worksheetTitle) {
        $api.setStorage(storageKey.wsNum, worksheetNo);
        $api.setStorage(storageKey.processId, processId);
        $api.setStorage(storageKey.wsTitle, worksheetTitle);
        api.openWin({
            name: 'worksheet_detail',
            bounces: false,
            slidBackEnabled : false,
            reload:true,
            url: './malfunction/worksheet_detail.html',
            vScrollBarEnabled:true,
            hScrollBarEnabled:false
        });
    }


    function openAppointPage(name){
        if (name===null){
            api.toast({
                msg: '此功能暂未开放！',
                duration: config.duration,
                location: 'middle'
            });
            return
        }
        api.openWin({
            name: name,
            bounces: false,
            slidBackEnabled : false,
            reload:true,
            url: './' + name + '.html',
            vScrollBarEnabled:true,
            hScrollBarEnabled:false
        });
    }

    function showOrClose(obj) {
        var isShow = $api.hasCls($api.next(obj), 'aui-show');
        if (isShow) {
            $api.removeCls($api.next(obj), 'aui-show');
            $api.addCls($api.next(obj), 'aui-hide');
        }else{
            $api.removeCls($api.next(obj), 'aui-hide');
            $api.addCls($api.next(obj), 'aui-show');
        }
    }
</script>
</html>
